@isTest
private class test_triggers {

	//tests Eingangsrechnung_BIBU, Ausgangsrechnung_BIBU, Kreditor_Invoice_Status_BIBU, Debitor_Invoice_Status_BIBU
    static testMethod void Rechnung_BIBU() {
    	Account acc = new Account(name = 'acc1');
    	insert acc;
    	Opportunity opp = new Opportunity(name = 'opp1', accountId = acc.id, StageName = 'Qualification', CloseDate = Date.Today()+4);
    	insert opp;
    	Chart_of_Accounts__c chAcc = new Chart_of_Accounts__c(Name = '7985417598143',Account_Type__c = 'Finanzen', Account_Description__c = 'Bank HVB *0343');
    	insert chAcc;
    	Chart_of_Accounts__c chAcc1 = new Chart_of_Accounts__c(Name = '7985417598143',Account_Type__c = 'Finanzen', Account_Description__c = 'Bank HVB *8380');
    	insert chAcc1;
    	Chart_of_Accounts__c chAcc2 = new Chart_of_Accounts__c(Name = '7985417598143',Account_Type__c = 'Finanzen', Account_Description__c = 'Deutsche Bank *3200');
    	insert chAcc2;
    	Chart_of_Accounts__c chAcc3 = new Chart_of_Accounts__c(Name = '7985417598143',Account_Type__c = 'Finanzen', Account_Description__c = 'Bank HVB *9333');
    	insert chAcc3;
    	/*Chart_of_Accounts__c chAcc4 = new Chart_of_Accounts__c(Name = '7985417598143',Account_Type__c = 'Finanzen', Account_Description__c = 'Bank');
    	insert chAcc4;
    	Chart_of_Accounts__c chAcc5 = new Chart_of_Accounts__c(Name = '7985417598143',Account_Type__c = 'Finanzen', Account_Description__c = 'Mastercard xx1000931');
    	insert chAcc5;
    	Chart_of_Accounts__c chAcc6 = new Chart_of_Accounts__c(Name = '7985417598143',Account_Type__c = 'Finanzen', Account_Description__c = 'Mastercard x20452043');
    	insert chAcc6;
    	Chart_of_Accounts__c chAcc7 = new Chart_of_Accounts__c(Name = '7985417598143',Account_Type__c = 'Finanzen', Account_Description__c = 'Mastercard xx9019208');
    	insert chAcc7;
    	*/Chart_of_Accounts__c chAcc8 = new Chart_of_Accounts__c(Name = '7985417598143',Account_Type__c = 'Finanzen', Account_Description__c = 'MasterCard Lufthansa TCS *0330');
    	insert chAcc8;
    	Chart_of_Accounts__c chAcc9 = new Chart_of_Accounts__c(Name = '7985417598143',Account_Type__c = 'Finanzen', Account_Description__c = 'MasterCard TCS *8341');
    	insert chAcc9;
    	Chart_of_Accounts__c chAcc10 = new Chart_of_Accounts__c(Name = '7985417598143',Account_Type__c = 'Finanzen', Account_Description__c = 'MasterCard THK *8333');
    	insert chAcc10;
    	/*Chart_of_Accounts__c chAcc11 = new Chart_of_Accounts__c(Name = '7985417598143',Account_Type__c = 'Finanzen', Account_Description__c = 'Kasse');
    	insert chAcc11;*/
        Kreditor__c EingangsRech = new Kreditor__c(Invoice_due_on__c = Date.Today()+4, Invoice_amount__c = 1000, 
        		Invoice_date__c = Date.Today(), Invoice_Number__c = '123',
        		VAT_Type__c = '19%', Opportunity__c = opp.id, Kreditorennummer__c = chAcc.id);
        insert EingangsRech;
        Kreditor_Invoice_Status__c EingangsRechStatus = new Kreditor_Invoice_Status__c(Kreditor_Invoice__c = EingangsRech.id, 
        			Payment_Status__c = 'Paid', Payment_method__c = 'Überweisung für Bank HVB *0343');
        insert EingangsRechStatus;
        Debitoren_Rechnung__c AusgangsRech = new Debitoren_Rechnung__c(VAT_Type__c = '19%', Opportunity__c = opp.id, Debitorennummer__c = chAcc.id);
        insert AusgangsRech;
        Debitor_Invoice_Status__c AusgangsRechStatus = new Debitor_Invoice_Status__c(Debitor_Invoice__c = AusgangsRech.id, 
        			Payment_Status__c = 'Paid', Payment_method__c = 'Bank transfer');
        insert AusgangsRechStatus;
        Debitor_Invoice_Status__c AusgangsRechStatus1 = new Debitor_Invoice_Status__c(Debitor_Invoice__c = AusgangsRech.id, 
        			Payment_Status__c = 'Paid', Payment_method__c = 'Bank transfer');
        try {
        	insert AusgangsRechStatus1; //fails, only one AusgangsRechnungStatus allowed
        } catch(Exception e) {}
    }
    
    
}